home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / mmdf / mmdf-IIb.43 / uip / send / s_drfile.c < prev    next >
Encoding:
C/C++ Source or Header  |  1986-02-01  |  1.3 KB  |  67 lines

  1. /*
  2. **        S _ D R F I L E
  3. **
  4. **   This file contains routines for opening and closing the draft file
  5. **   and for truncating the draft file.
  6. **
  7. **
  8. **    R E V I S I O N  H I S T O R Y
  9. **
  10. **    03/31/83  GWH    Split the SEND program into component parts
  11. **            This module contains dropen and drclose.
  12. **
  13. */
  14.  
  15. #include "./s.h"
  16. #include "./s_externs.h"
  17.  
  18. dropen (seektype)
  19.     int seektype;
  20. {
  21.     extern long lseek ();
  22.  
  23.     if (drffd <= 0)
  24.     {
  25.     if ((drffd = open (drffile, 2)) < 0)
  26.     {
  27.         printf ("Unable to open draft '%s'.\n", drffile);
  28.         fflush (stdout);
  29.         s_exit (-1);
  30.     }
  31.     if (chmod (drffile, 0400) < 0)
  32.     {                         /* protect against crashes            */
  33.         printf ("Unable to protect draft '%s'.\n", drffile);
  34.         fflush (stdout);
  35.         s_exit (-1);
  36.     }
  37.     }
  38.     lseek (drffd, 0L, seektype);
  39. }
  40.  
  41. drclose ()
  42. {
  43.     if (drffd > 0)
  44.     {
  45.     close (drffd);
  46.     drffd = 0;
  47.     if (chmod (drffile, sentprotect) < 0)
  48.     {                         /* protect against crashes            */
  49.         printf ("Unable to unlock draft '%s'.\n", drffile);
  50.         fflush (stdout);
  51.     }
  52.     }
  53. }
  54.  
  55. drempty ()
  56. {
  57.     drclose ();
  58.     if ((drffd = creat(drffile, sentprotect)) >= 0)
  59.         drclose ();
  60.     else
  61.     {
  62.     printf(" Can't open draft file '%s'.\n", drffile);
  63.     fflush (stdout);
  64.     s_exit( NOTOK );
  65.     }
  66. }
  67.